/*-
 * Copyright (c) 2008 Nils Dijk, Michiel van den Anker, Oscar Orton,
 *  Tonny Wildeman, Arjan van der Velde
 *
 * TIGAM, Hogeschool van Amsterdam
 * http://www.tigam.com, http://home.ie.hva.nl
 * 
 * All rights reserved
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions are
 * met:
 *
 *     * Redistributions of source code must retain the above copyright
 *       notice, this list of conditions and the following disclaimer.
 *     * Redistributions in binary form must reproduce the above
 *       copyright notice, this list of conditions and the following
 *       disclaimer in the documentation and/or other materials provided
 *       with the distribution.
 *     * The name of the author may not be used to endorse or promote
 *       products derived from this software without specific prior
 *       written permission.
 *
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 */

/**
 * 
 */
package com.tigam.railcab.gui.editor.tools;

import javax.swing.BorderFactory;
import javax.swing.JPanel;

import com.tigam.railcab.gui.editor.baan.BaanPanel;
import com.tigam.railcab.gui.editor.model.Baan;
import com.tigam.railcab.language.Language;
import com.tigam.railcab.language.LanguageListener;

/**
 * @author ThaNOD.nl
 * 
 */
public abstract class Tool extends JPanel implements LanguageListener {
	/**
	 * Een referentie naar de editor
	 */
	protected BaanPanel editor;

	/**
	 * Een referentie naar de baan controller
	 */
	protected Baan baan;

	/**
	 * De key die in Language moet worden opgezocht voor deze titel
	 */
	private String borderTextLanguage;

	/**
	 * Vul alle belangrijke waarde in
	 * 
	 * @param baan de baan controller
	 * @param editor de editor (BaanPanel)
	 */
	public Tool(Baan baan, BaanPanel editor) {
		this.baan = baan;
		this.editor = editor;
		borderTextLanguage = null;
		Language.addLanguageListener(this);
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see com.tigam.railcab.language.LanguageListener#LanguageChanged()
	 */
	public void LanguageChanged() {
		if (borderTextLanguage == null) {
			setBorder(BorderFactory.createTitledBorder(""));
		} else {
			setBorder(BorderFactory.createTitledBorder(Language.getString(borderTextLanguage)));
		}
	}

	/**
	 * Geef de key op voor de Language
	 * 
	 * @param key
	 */
	protected void setBorderTextLanguage(String key) {
		borderTextLanguage = key;
		LanguageChanged();
	}
}
